class ParamsTypeError(Exception):
    """参数类型错误"""
    pass


def using_for_loop(n):
    """使用 for 循环，求斐波那契数列"""
    i, j = 0, 1

    try:
        n = int(n)
    except Exception:
        raise ParamsTypeError("please input Integer")

    if n == 1:
        return 0
    if n == 2:
        return 1
    for _ in range(n - 2):
        i, j = j, j + i
    return j


def using_while_loop(n):
    """使用 while 循环，求斐波那契数列"""
    i, j = 0, 1

    try:
        n = int(n)
    except Exception:
        raise ParamsTypeError("please input Integer")

    if n == 1:
        return 0
    if n == 2:
        return 1
    while n-2 > 0:
        n -= 1
        i, j = j, j+i
    return j


def using_for_recurrence(n):
    """使用递归，求斐波那契数列"""
    try:
        n = int(n)
    except Exception:
        raise ParamsTypeError("please input Integer")

    if n == 1:
        return 0
    if n == 2:
        return 1
    return using_for_recurrence(n - 1) + using_for_recurrence(n - 2)


if __name__ == '__main__':
    a = using_for_loop('n')
    b = using_for_recurrence(10)
    print(a, b)